module frontend.Parser;
import frontend.Model;
import frontend.Loader;
import loader.Cfg;

Model loadModel(char[] dmcpath){
	scope auto cfgLoader = new CfgLoader;
	cfgLoader.load(dmcpath);
	auto mapCfg = cfgLoader.result();
	auto node = mapCfg.child("modelFile");
	char[] filename= node.string_("filename");
	char[] modelname= node.string_("modelname");
	char[] animationname = "";
	float t=node.float_("tadaptibility");
	float r=node.float_("radaptibility");
	float animationspeed=0;
	node = node.child("animation"); 

	animationname= node.string_("name");
	animationspeed= node.float_("speed");

	Model m=frontend.Loader.loadModel(filename,modelname, animationname, animationspeed);
	m.skeleton.setAdaptibilities(t,r);
	
	
	for(int i=0; i< mapCfg.count("animation"); ++i){
		node=mapCfg.child("animation",i);
		filename=node.string_("filename");
		animationname=node.string_("name");
		animationspeed=node.float_("speed");
		
		addAnimation(m, filename,modelname,animationname,animationspeed);
	}
	
	return m;
}